<!-- 提示信息 -->
<app-tip [type]="tipType"></app-tip>
<!--<app-load *ngIf="isLoading"></app-load>-->

<div class="header">
  <div class="left flex left-header-box" [routerLink]="['/main/ess/material']" id="btn-back">
    <div class="left-icon">
      <i class="fa fa-angle-left back-icon" aria-hidden="true"></i>
    </div>
    <div class="left-name">
      <span class="back-name">返回</span>
    </div>
  </div>
  <div class="center">添加物料</div>
</div>

<div class="main">
  <form>
    <div class="yami-form">
      <div class="yami-form-item">
        <label class="yami-label">物料名称</label>
        <div class="yami-input-block">
          <input type="text" name="name" class="yami-input" placeholder="输入物料名称" [(ngModel)]="editInfo['mt.name']">
        </div>
      </div>
      <div class="yami-form-item">
        <label class="yami-label">物料单位</label>
        <div class="yami-input-block">
          <div><i class="fa fa-plus-circle" style="font-size: 1.6em;color: silver;vertical-align: middle" (click)="addUnit()"></i></div>
         <div *ngFor="let v of editInfo['mt.unit'];let index=index;">
           <div *ngIf="index>0">=</div>
           <div class="number-unit">
             <input type="number" [name]="v.index?v.index:index+1" placeholder="输入数量" [(ngModel)]="v.conversion">
             <input type="text" [name]="v.unit?v.unit:v.mark" placeholder="输入单位" [(ngModel)]="v.unit">
             <div style="clear: both;"></div>
             <i class="closeXR fa fa-times-circle" (click)="deleteUnit(index)"></i>
           </div>
         </div>
        </div>
      </div>
      <div class="yami-form-item">
        <label class="yami-label">排序数</label>
        <div class="yami-input-block">
          <input type="number" name="sort" class="yami-input" placeholder="输入物料排序" [(ngModel)]="editInfo['mt.sort']">
        </div>
      </div>
      <div class="yami-form-item">
        <label class="yami-label">绑定物料</label>
        <div class="yami-input-block">
          <div class="select-box">
            <div class="layui-select search-select" style="display: inline-block" (click)="isShowList($event)">{{foodName}}</div>
            <div class="search-box" [hidden]="!showList || foodList.length<10">
              <input type="text" #inp class="search-input" placeholder="搜索关键字" (input)="searchKey($event, inp)">
              <!--<i class="fa fa-search"></i>-->
            </div>
            <ul class="chooseList" [hidden]="!showList">
              <li (click)="clearChoose()">选择</li>
              <li *ngFor="let v of foodList" (click)="chooseRes(v)" [hidden]="v.show">{{v.name}}</li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </form>

  <!--提交-->
  <div style="padding: 0 1em 1em 1em;margin-top: 1em;">
    <div class="btn-submit" (click)="save()">保存</div>
  </div>
</div>
